package dao;

import model.Location;
import model.MapObject;

public class Field {
	
	private Object[][] field;
	private int depth;
	private int width;
	
	
	public Field(int depth, int width){
		this.depth = depth;
		this.width = width;
		field = new Object[depth][width];
	}

		
	
    public void clear()
    {
        for(int row = 0; row < depth; row++) {
            for(int col = 0; col < width; col++) {
                field[row][col] = null;
            }
        }
    }
    
    
    public void clearLocation(Location location)
    {
        field[location.getRow()][location.getCol()] = null;
    }
    
   
    public void place(MapObject mapObject, int row, int col)
    {
        place(mapObject, new Location(row, col));
    }
    
    public void place(MapObject mapObject, Location location)
    {
        field[location.getRow()][location.getCol()] = mapObject;
    }
    
    public Object getObjectAt(Location location)
    {
        return getObjectAt(location.getRow(), location.getCol());
    }
    
    public Object getObjectAt(int row, int col)
    {
        return field[row][col];
    }
	
	public int getDepth() {
		return depth;
	}


	public void setDepth(int depth) {
		this.depth = depth;
	}


	public int getWidth() {
		return width;
	}

	public void setWidth(int width) {
		this.width = width;
	}
	
	
}
